//
//  LoginViewController.m
//  group14
//
//  Created by lanou3g on 15/11/11.
//  Copyright © 2015年 吕志伟. All rights reserved.
//

#import "LoginViewController.h"
#import "SpeakOthers.h"
@interface LoginViewController ()
@property (strong, nonatomic) IBOutlet UITextField *UserNameTextFields;
@property (strong, nonatomic) IBOutlet UITextField *PassWordTextFields;

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
}
- (IBAction)loginButton:(UIButton *)sender {
    
    if (_UserNameTextFields != nil) {
        
        [AVUser logInWithUsernameInBackground:_UserNameTextFields.text password:_PassWordTextFields.text block:^(AVUser *user, NSError *error) {
            if (user != nil) {
                
                UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                
                UITabBarController *bar = [sb instantiateViewControllerWithIdentifier:@"tabbar"];
                
                
                [UIApplication sharedApplication].keyWindow.rootViewController = bar;
                
            } else {
                
                UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"提示:" message:@"请确认用户名密码" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
                 [av show];
                
            }
        }];
        
    }else
    {
        UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"提示:" message:@"用户名不能为空:" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [av show];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
